/* eslint-disable @typescript-eslint/no-explicit-any */
import LinkCard from "@/components/LinkCard";
import PinyinText from "@/components/PinyinText";
import RequestList from "@/components/requestList";
import { ChevronRight, User } from "lucide-react";

export default async function Poet({
  searchParams,
}: {
  searchParams?: Promise<{ [key: string]: string | undefined }>;
}) {
  const searchParamsData = await searchParams;
  return (
    <RequestList
      config={{ url: "/api/poet/list", options: { method: "POST" } }}
      searchParams={searchParamsData}
      pageSize={12}
      renderFunc={(list) => {
        return (
          <div className="grid grid-cols-1 md:grid-cols-3 gap-4 p-5 md:p-0">
            {list.map((item: any, index) => (
              <LinkCard key={index} path={`/poet/${item.id}`}>
                <div
            // className="group block p-6 rounded-xl bg-slate-800/50 border border-slate-700 hover:border-emerald-500/50 transition-all"
          >
            <div className="flex items-start justify-between">
              <div className="flex items-center space-x-4">
                <div className="p-3 rounded-lg bg-slate-700/50 text-emerald-400">
                  <User className="h-6 w-6" />
                </div>
                <div>
                  <h3 className="text-xl font-semibold group-hover:text-emerald-400">
                  <PinyinText text={item.name} />
                  </h3>
                  <span className="text-slate-400 block">
                    <PinyinText text={item.dynasty} />
                  </span>
                </div>
              </div>
              <ChevronRight className="h-5 w-5 text-slate-500 group-hover:text-emerald-400" />
            </div>
            <p className="mt-4 text-sm text-slate-400">
              {item.birthday?new Date(item.birthday).getFullYear():'未知'} - {item.deadyear?new Date(item.deadyear).getFullYear():'未知'}
            </p>
          </div>
              </LinkCard>
            ))}
          </div>
        );
      }}
    />
  );
}
